import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

///flutter跳转到原生界面
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomePageView(),
    );
  }
}

class HomePageView extends StatefulWidget {
  const HomePageView({Key? key}) : super(key: key);

  @override
  _HomePageViewState createState() => _HomePageViewState();
}

class _HomePageViewState extends State<HomePageView> {
  @override
  Widget build(BuildContext context) {
    const demoPlugin = MethodChannel("demo.plugin");
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: const Text("flutter和Android的交互"),
      ),
      body: Column(
        children: [
          ElevatedButton(
              onPressed: () {
                demoPlugin.invokeMethod("interaction");
              },
              child: const Text("界面跳转到Android界面"))
        ],
      ),
    );
  }
}
